/******************************************************************************

 ******************************************************************************
  File Name	:osd.h
  Version		:001
  Author		:liangH
  Description	:define osd class
  History		:20120705 new
  Modification	: 

******************************************************************************/
#ifndef __OSD_H__
#define __OSD_H__

#include "config.h"

/*if define SUPPORT_COLOR_ARGB8888, then uses color of 32bit, else use ARGB1555*/
#if defined(SUPPORT_COLOR_ARGB8888)/*color data type*/
	#define color_t unsigned long/*32bit*/
	#define COLOR_VALUE(a, r, g, b) (((a) << 24) | ((r) << 16) | ((g) << 8) | (b))
#else
	#define color_t unsigned short/*16bit*/
	#define COLOR_VALUE(a, r, g, b) (((a > 0)?0x8000:0) | (((r >> 3) & 0x1f) << 10) | (((g >> 3) & 0x1f) << 5) | ((b >> 3) & 0x1f))
#endif

typedef enum _resolution_{/*resolution*/
	RES_D1 = 0,
	RES_HD1,
	RES_CIF,
	RES_QCIF,
	RES_MOBILE,
	RES_720P
}resolution_t;

class Osd{
	/*variable*/
	private: 
		unsigned char	osd_time_switch[4];/*osd time switch of four channel, 0 shows time osd is closed and 1 shows time osd is opened*/
		unsigned char	osd_gps_switch[4];/*osd gps switch of four channel, 0 shows gps osd is closed and 1 shows gps osd is opened*/
		unsigned char	osd_bus_switch[4];/*osd bus switch of four channel, 0 shows bus osd is closed and 1 shows bus osd is opened*/
		unsigned char	osd_company_switch[4];/*osd company switch of four channel, 0 shows company osd is closed and 1 shows company osd is opened*/
		unsigned char	vi_status[4];/*osd status of four channel, 0 shows no display and 1 shows display*/
		unsigned short vi_osd_x[4];/*osd x coordinate of four channel*/
		unsigned short vi_osd_y[4];/*osd y coordinate of four channel*/
		unsigned short vi_osd_height[4];/*osd height of four channel*/
		unsigned short vi_osd_width[4];/*osd width of four channel*/
		unsigned short vi_osd_size[12];/*osd data size of four channel*/
		unsigned char bus_color[4];/*background color of four channel*/
		unsigned char bus_font_size[4];/*the font size of bus area, four channel*/
		unsigned char company_color[4];/*background color of four channel*/
		unsigned char company_font_size[4];/*the font size of company area, four channel*/
		unsigned char resolution[4];/*resolution of four channel*/
		REGION_HANDLE vi_time_handle[4];/*vi osd time handle of four channel*/
		REGION_HANDLE vi_channel_handle[12];/*vi osd channel handle of four channel*/
		unsigned char vi_osd_channel_flag[12];/*osd channel flag, 0 shows no osd channel content and 1 shows osd channel content*/
		unsigned char vi_osd_time_flag[4];/*osd time flag, 0 shows no osd time and 1 shows osd time*/
		char vi_osd_data[12][MAX_OSD_BUFFER_SIZE];/*osd data of four channel*/
		REGION_CTRL_PARAM_U time_vi_control_param[4];/*time control parameter of osd*/
		REGION_CTRL_PARAM_U channel_vi_control_param[12];/*channel control parameter of osd*/
		REGION_HANDLE time_vi_osd[4];/*time region handle of four channel*/
		REGION_HANDLE chn_vi_osd[4];/*channel region handle of four channel*/
		pthread_mutex_t vi_osd_time_lock[4];/*vi osd time lock of four channel*/
		pthread_t vi_osd_dispalythread[4];/*vi osd display thread of four channel*/
		pthread_t osd_gps_dispalythread[4];/*osd gps display thread of four channel*/
		pthread_mutex_t read_write_lock;/*read and write lock*/
		HI_BOOL gps_flag_1;/*the flag of gps thread of channel 1*/
		HI_BOOL gps_flag_2;/*the flag of gps thread of channel 2*/
		HI_BOOL gps_flag_3;/*the flag of gps thread of channel 3*/
		HI_BOOL gps_flag_4;/*the flag of gps thread of channel 4*/
		
		FILE *ascfd;/*fd of asc16*/
		FILE *hzkfd;/*fd of hzk16*/
		FILE *ascfd12;/*fd of asc12*/
		FILE *hzkfd12;/*fd of hzk12*/
	/*constructed function and deconstructed function*/
	public:
		Osd();/*constructed function*/
		~Osd();/*deconstructed function*/

	public:
	/*set,get member functin*/
		void set_osd_time_switch(unsigned char channelID, unsigned char temp_osd_time_switch);
		unsigned char get_osd_time_switch(unsigned char channelID);
		void set_osd_gps_switch(unsigned char channelID, unsigned char temp_osd_gps_switch);
		unsigned char get_osd_gps_switch(unsigned char channelID);
		void set_osd_bus_switch(unsigned char channelID, unsigned char temp_osd_bus_switch);
		unsigned char get_osd_bus_switch(unsigned char channelID);
		void set_osd_company_switch(unsigned char channelID, unsigned char temp_osd_company_switch);
		unsigned char get_osd_company_switch(unsigned char channelID);
		void set_vi_status(unsigned char channelID, unsigned char temp_vi_status);
		unsigned char get_vi_status(unsigned char channelID);
		void set_vi_osd_x(unsigned char channelID, unsigned short temp_vi_osd_x);
		unsigned short get_vi_osd_x(unsigned char channelID);
		void set_vi_osd_y(unsigned char channelID, unsigned short temp_vi_osd_y);
		unsigned short get_vi_osd_y(unsigned char channelID);
		void set_vi_osd_h(unsigned char channelID, unsigned short temp_vi_osd_h);
		unsigned short get_vi_osd_h(unsigned char channelID);
		void set_vi_osd_w(unsigned char channelID, unsigned short temp_vi_osd_w);
		unsigned short get_vi_osd_w(unsigned char channelID);
		void set_vi_osd_size(unsigned char channelID, unsigned char regionID, unsigned short temp_vi_osd_size);
		unsigned short get_vi_osd_size(unsigned char channelID, unsigned char regionID);
		void set_bus_color(unsigned char channelID, unsigned char temp_bus_color);
		unsigned char get_bus_color(unsigned char channelID);
		void set_company_color(unsigned char channelID, unsigned char temp_company_color);
		unsigned char get_company_color(unsigned char channelID);
		unsigned char get_bus_font_size(unsigned char channelID);
		void set_bus_font_size(unsigned char channelID, unsigned char temp_bus_font_size);
		unsigned char get_company_font_size(unsigned char channelID);
		void set_company_font_size(unsigned char channelID, unsigned char temp_company_font_size);
		void set_vi_osd_time_flag(unsigned char channelID, unsigned char temp_vi_osd_time_flag);
		unsigned char get_vi_osd_time_flag(unsigned char channelID);
		void set_vi_osd_channel_flag(unsigned char channelID, unsigned char regionlID, unsigned char temp_vi_osd_channel_flag);
		unsigned char get_vi_osd_channel_flag(unsigned char channelID, unsigned char regionlID);
		void set_vi_osd_data(unsigned char channelID, unsigned char regionID, char *temp_vi_osd_data);
		void set_vi_osd_data(unsigned char channelID, unsigned char regionID, unsigned char *temp_vi_osd_data, unsigned char data_size);
		void get_vi_osd_data(unsigned char channelID, unsigned char regionID, char *temp_vi_osd_data);
		void set_gps_flag_1(HI_BOOL temp_gps_flag_1);
		HI_BOOL get_gps_flag_1();
		void set_gps_flag_2(HI_BOOL temp_gps_flag_2);
		HI_BOOL get_gps_flag_2();
		void set_gps_flag_3(HI_BOOL temp_gps_flag_3);
		HI_BOOL get_gps_flag_3();
		void set_gps_flag_4(HI_BOOL temp_gps_flag_4);
		HI_BOOL get_gps_flag_4();
	/*set,get member functin end*/

	/*basic function*/
		void vi_osd_time_thread_body(void* para);
		void vi_gps_thread_body_1(void* para);
		void vi_gps_thread_body_2(void* para);
		void vi_gps_thread_body_3(void* para);
		void vi_gps_thread_body_4(void* para);
		int show_vi_osd_time(unsigned char channelID);
		int show_vi_gps(unsigned char channelID);
		HI_S32 show_vi_osd_channel(unsigned char channelID, unsigned char regionID);
		int delete_vi_osd_channel(unsigned char channelID, unsigned char regionID,  unsigned char region_flag);
		HI_S32 stop_vi_time_thread(unsigned char channelID);
		HI_S32 stop_vi_gps_thread(unsigned char channelID);
	/*basic function end*/
	
	private:	
	/*inside process function*/
		int show_vi_fixed_time(unsigned char channelID, char * text);
		int osd_find_asc_from_lib(char * tx, unsigned char* buffer);
		int osd_find_asc12_from_lib(char * tx, unsigned char* buffer);
		int osd_find_hzk_from_lib(char * tx, unsigned char* buffer);
		int osd_find_hzk12_from_lib(char * tx, unsigned char* buffer);
		void osd_to_RGB(unsigned int zcolor, unsigned int bcolor, int len, unsigned char * s, unsigned char *d, resolution_t encode_flag, unsigned char *text_flag, unsigned char channelID, unsigned char regionID);
		int show_vi_fixed_text(unsigned char channelID, unsigned char regionID);
		int vi_overlay_create_region(unsigned char channelID, unsigned char regionID, unsigned char region_flag);
	/*inside process function end*/
	
};

#endif

